package com.dk.service.impl;

import com.dk.Vo.PublisherVo;
import com.dk.mapper.PublisherMapper;
import com.dk.pojo.Publisher;
import com.dk.pojo.PublisherExample;
import com.dk.service.PublisherServiceI;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PublisherServiceImpl implements PublisherServiceI {

    @Autowired
    private PublisherMapper publisherMapper;

    @Override
    public PageInfo<PublisherVo> getInfoServer(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<PublisherVo> list = publisherMapper.getInfoServer();
        PageInfo<PublisherVo> page = new PageInfo<>(list);
        return page;
    }

    @Override
    public void addById(Publisher publisher) {
        publisherMapper.insertSelective(publisher);
    }

    @Override
    public Publisher getUpdateInfo(Integer pubId) {
        return publisherMapper.selectByPrimaryKey(pubId);
    }

    @Override
    public void updateById(Publisher publisher) {
        publisherMapper.updateByPrimaryKeySelective(publisher);
    }

    @Override
    public void deleteById(Integer pubId) {
        publisherMapper.deleteByPrimaryKey(pubId);
    }

    @Override
    public List<Publisher> getInfo() {
        return publisherMapper.selectByExample(new PublisherExample());
    }
}
